---
title: gluestack-ui Fab Component | Installation, Usage, and API

description: The Floating Action Button (FAB) is a dynamic button that stays visible and provides access to a primary action throughout the user's journey in the application. It is a powerful UI element that adds a touch of elegance and convenience to the user experience.

pageTitle: Fab

pageDescription: The Floating Action Button (FAB) is a dynamic button that stays visible and provides access to a primary action throughout the user's journey in the application. It is a powerful UI element that adds a touch of elegance and convenience to the user experience.

showHeader: true
---

import { Meta } from '@storybook/addon-docs';

<Meta title="with-gluestack-style/Components/Others/Fab" />

import { Fab, FabIcon, FabLabel } from '../../core-components/themed';
import {
  Checkbox,
  CheckboxIndicator,
  CheckboxLabel,
  Image,
  Box,
  Link,
  HStack,
  VStack,
  Avatar,
  AvatarImage,
  Heading,
  Text,
  Divider,
  AddIcon,
  CheckboxIcon
} from '../../core-components/themed';
import { transformedCode } from '../../utils';
import { EditIcon, SearchIcon, ShoppingCartIcon, CheckIcon } from 'lucide-react-native';
import {
  AppProvider,
  CodePreview,
  Table,
  TableContainer,
  InlineCode,
  CollapsibleCode,
  Tabs
} from '@gluestack/design-system';
import Wrapper from '../../core-components/themed/Wrapper';

This is an illustration of **Fab** component.

<Wrapper>
  <CodePreview
    showComponentRenderer={true}
    showArgsController={true}
    metaData={{
      code: `
        <Box
          h={360}
          w={320}
          bg="$backgroundLight50"
          $dark-bg="$backgroundDark900"
          borderRadius="$md"
        >
          <Fab {...props}>
            <FabIcon as={AddIcon} mr="$1"/>
            <FabLabel>Quick start</FabLabel>
          </Fab>
        </Box>
      `,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: { Box, Wrapper, Fab, FabIcon, FabLabel, AddIcon },
      argsType: {
        size: {
          control: 'select',
          options: ['sm', 'md', 'lg'],
          default: 'md',
        },
        placement: {
          control: 'select',
          options: [
            'top left',
            'top center',
            'top right',
            'bottom left',
            'bottom center',
            'bottom right',
          ],
          default: 'bottom right',
        },
        isHovered: {
          control: 'boolean',
          options: [true, false],
          default: false,
        },
        isDisabled: {
          control: 'boolean',
          options: [true, false],
          default: false,
        },
        isPressed: {
          control: 'boolean',
          options: [true, false],
          default: false,
        },
      },
    }}
  />
</Wrapper>

<br />

## Installation

<Tabs value="cli" type="section">
  <Tabs.TabList>
      <Tabs.Tab value="cli">
        <Tabs.TabTitle>CLI</Tabs.TabTitle>
      </Tabs.Tab>
     <Tabs.Tab value="manual">
        <Tabs.TabTitle>Manual</Tabs.TabTitle>
     </Tabs.Tab>
  </Tabs.TabList>
  <Tabs.TabPanels>
    <Tabs.TabPanel value="cli">
<>

### Run the following command:
  ```bash
  npx gluestack-ui add fab
  ```
</>
    </Tabs.TabPanel>
    <Tabs.TabPanel value="manual"> 
<>

### Step 1: Install the following dependencies:
```bash
npm i @gluestack-ui/fab
```

### Step 2: Copy and paste the following code into your project.
<CollapsibleCode>

```jsx 
%%-- File: core-components/themed/fab/index.tsx --%% 
```
</CollapsibleCode>

### Step 3: Update the import paths to match your project setup.
</>
    </Tabs.TabPanel>
  </Tabs.TabPanels>
</Tabs>

### API Reference

To use this component in your project, include the following import statement in your file.

```jsx
import { Fab } from '@gluestack-ui/themed';
```

```jsx
export default () => (
  <Fab>
    <FabLabel />
    <FabIcon />
  </Fab>
);
```

#### Fab

Contains all fab related layout style props and actions.
It inherits all the properties of React Native's [Pressable](https://reactnative.dev/docs/pressable) component.

<Wrapper>
  <TableContainer>
    <Table>
      <Table.THead>
        <Table.TR>
          <Table.TH>
            <Table.TText>Prop</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Type</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Default</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Description</Table.TText>
          </Table.TH>
        </Table.TR>
      </Table.THead>
      <Table.TBody>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>placement</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>
              "top left" | "top right" | "bottom left" | "bottom right" | "top
              center" | "bottom center"
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>"bottom right"</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>{`Placement of the Fab`}</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>isHovered</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>bool</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>false</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>{`To manually set hover to the fab.`}</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>isPressed</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>bool</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>false</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>{`To manually set pressable state to the fab.`}</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>isFocused</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>bool</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>false</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>{`To manually set focused state to the fab.`}</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>isDisabled</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>bool</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>false</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>{`To manually set disable to the fab.`}</Table.TText>
          </Table.TD>
        </Table.TR>
      </Table.TBody>
    </Table>
  </TableContainer>
</Wrapper>

#### FabLabel

Contains all text related layout style props and actions.
It inherits all the properties of React Native's [Text](https://reactnative.dev/docs/text) component.

#### FabIcon

Contains all Icon related layout style props and actions. It inherits all the properties of Gluestack Style's [AsForwarder](/style/docs/api/as-forwarder) component.

### Features

- Keyboard support for actions.
- Support for hover, focus and active states.
- Option to add your styles or use the default styles.

### Accessibility

We have outlined the various features that ensure the Fab component is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards.Adheres to the [WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/)

#### Keyboard

- `Tab`: Moves focus to the next focusable element.
- `Shift + Tab`: Moves focus to the previous focusable element.
- `Enter`: Triggers the fab's action.

#### Screen Reader

- VoiceOver: When the fab is focused, the screen reader will announce the fab's label and its current state.

#### Focus Management

- The `onFocus` and `onBlur` props manage focus states and provide visual cues to users. This is especially important for users who rely on keyboard navigation.

### Dependencies

The following are the lists of all the libraries and packages the component relies on. This information will help you ensure that your project has all the necessary dependencies installed to use the component.

- `@gluestack-ui/utils`
- `@react-native-aria/focus`
- `@react-native-aria/interactions`

### Props

Fab component is created using Pressable component from react-native. It extends all the props supported by [React Native Pressable](https://reactnative.dev/docs/pressable#props), [utility props](/ui/docs/styling/utility-and-sx-props) and the props mentioned below.

#### Fab

<Wrapper>
  <TableContainer>
    <Table>
      <Table.THead>
        <Table.TR>
          <Table.TH>
            <Table.TText>Name</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Value</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Default</Table.TText>
          </Table.TH>
        </Table.TR>
      </Table.THead>
      <Table.TBody>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>size</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>sm | md | lg</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>md</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>placement</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>
              top right | top left | bottom right | bottom left | top center |
              bottom center
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>bottom right</Table.TText>
          </Table.TD>
        </Table.TR>
      </Table.TBody>
    </Table>
  </TableContainer>
</Wrapper>

### Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

#### FAB with Icon

A Fab component with an icon adds a visually striking and easily recognizable button that triggers a specific action or function within a user interface.

<Wrapper>
  <CodePreview
    _rendererWrapper={{ py: '$8' }}
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
        function App() {
          const data = [
            {
              uri: 'https://images.unsplash.com/photo-1599566150163-29194dcaad36?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80',
              name: 'Kevin James',
              msg: 'Hi Rachel, What\\'s up',
            },
            {
              uri: 'https://images.unsplash.com/photo-1527980965255-d3b416303d12?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1180&q=80',
              name: 'Jacob Jones',
              msg: 'Good Morning!',
            },
            {
              uri: 'https://images.unsplash.com/photo-1633332755192-727a05c4013d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1180&q=80',
              name: 'Albert Flores',
              msg: 'Coffee?',
            },
          ];
          return (
            <Box
              borderColor='$borderLight200'
              borderRadius='$lg'
              borderWidth='$1'
              p='$6'
              $dark-bg='$backgroundDark900'
              $dark-borderColor='$borderDark800'
              $base-minWidth={240}
              $sm-minWidth={360}
              $md-minWidth={476}
            >
              <VStack space='md'>
                {data.map((chatData)=>{
                  return (
                    <HStack space='sm' alignItems='center'>
                      <Avatar size='sm'>
                        <AvatarImage
                          source={{
                          uri: chatData.uri,
                          }}
                        />
                      </Avatar>
                      <VStack>
                        <Heading size='xs'>
                          {chatData.name}
                        </Heading>
                        <Text size='xs'>
                          {chatData.msg}
                        </Text>
                      </VStack>
                    </HStack>
                  );
                })}
              </VStack>
              <Fab bg="$emerald600" size='lg'>
                {/* EditIcon is imported from 'lucide-react-native' */}
                <FabIcon as={EditIcon}/>
              </Fab>
            </Box>
          );
        }
      `,
      transformCode: (code) => {
        return transformedCode(code, 'function', 'App');
      },
      scope: {
        Fab,
        FabIcon,
        Wrapper,
        EditIcon,
        Box,
        VStack,
        HStack,
        Avatar,
        AvatarImage,
        Heading,
        Text,
      },
      argsType: {},
    }}
  />
</Wrapper>

#### FAB with Icon and Text

A Fab component with an icon and text combines a visual icon with accompanying text to create a prominent and descriptive button that triggers a specific action or function within a user interface.

<Wrapper>
  <CodePreview
    _rendererWrapper={{ py: '$8' }}
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
        <Box
          maxWidth='$96'
          borderColor='$borderLight200'
          rounded='$lg'
          borderWidth='$1'
          py={56}
          px='$6'
          $base-mx='$5'
          $dark-bg='$backgroundDark900'
          $dark-borderColor='$borderDark800'
        >
          <Fab bg="$primary600" height="$9" top='$4'>
            <FabIcon as={SearchIcon}  mr="$1.5"/>
            <FabLabel >Search</FabLabel>
          </Fab>
          <VStack space='lg'>
            <Box>
              <Text fontSize='$xs' color='$darkBlue600' fontWeight='$bold'  
              $dark-color='$darkBlue400'>
                HEALTH
              </Text>
              <Heading size='sm'>
                Benefits of Oranges
              </Heading>
              <Text size='xs' mt='$1.5'>
                Oranges are a great source of vitamin C, which is essential for a healthy immune system.
              </Text>
              <HStack space='sm' mt='$3' h='$5'>
                <Text size='xs'>
                  Wade Warrem
                </Text>
                <Divider
                  orientation='vertical'
                  bg="$backgroundLight300"
                  $dark-bg="$backgroundLight700"
                />
                <Text size='xs'>
                  6th Oct, 2019
                </Text>
                <Divider
                  orientation='vertical'
                  bg="$backgroundLight300"
                  $dark-bg="$backgroundLight700"
                />
                <Text size='xs'>
                  5 mins read
                </Text>
              </HStack>
            </Box>
            <Divider />
            <Box>
              <Text fontSize='$xs' color='$darkBlue600' fontWeight='$bold' $dark-color='$darkBlue400'>
                TECHNOLOGY
              </Text>
              <Heading size='sm' >
                How AI can benefit your business
              </Heading>
              <Text size='xs'  mt='$1.5'>
                AI can automate tasks and processes, allowing for increasing efficiency and productivity.
              </Text>
              <HStack space='sm' mt='$3' h='$5'>
                <Text size='xs' >
                  Wade Warrem
                </Text>
                <Divider
                  orientation='vertical'
                  bg="$backgroundLight300"
                  $dark-bg="$backgroundLight700"
                />
                <Text size='xs'>
                  6th Oct, 2019
                </Text>
                <Divider
                  orientation='vertical'
                  bg="$backgroundLight300"
                  $dark-bg="$backgroundLight700"
                />
                <Text size='xs'>
                  5 mins read
                </Text>
              </HStack>
            </Box>
          </VStack>
        </Box>
      `,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Fab,
        FabIcon,
        FabLabel,
        Wrapper,
        SearchIcon,
        Box,
        Divider,
        Heading,
        Text,
        HStack,
        VStack,
      },
      argsType: {},
    }}
  />
</Wrapper>

#### Placement

A Fab component with placement options allows for flexible positioning of the button within a user interface, enabling convenient and intuitive access to key actions or functionalities in various locations.

<Wrapper>
  <CodePreview
    _rendererWrapper={{ py: '$8' }}
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
        <Box
          borderColor="$borderLight300"
          rounded="$lg"
          borderWidth="$1"
          py="$4"
          bg="$white"
          $base-mx="$5"
          $dark-bg="$backgroundDark900"
          $dark-borderColor="$borderDark800"
        >
          <VStack mb='$2' px='$6' py ='$2' space='lg'>
            <Checkbox size="sm" >
              <CheckboxIndicator mr="$2" >
                <CheckboxIcon as={CheckIcon} />
              </CheckboxIndicator>
              <CheckboxLabel>
                <Text fontSize='$sm'  >
                  Prepare any feedback or updates.
                </Text>
              </CheckboxLabel>
            </Checkbox>
            <Checkbox size="sm">
              <CheckboxIndicator mr="$2" >
                <CheckboxIcon as={CheckIcon} />
              </CheckboxIndicator>
              <CheckboxLabel>
                <Text fontSize='$sm' >
                  Review progress on goals and projects.
                </Text>
              </CheckboxLabel>
            </Checkbox>
            <Checkbox size="sm">
              <CheckboxIndicator mr="$2" >
                <CheckboxIcon as={CheckIcon} />
              </CheckboxIndicator>
              <CheckboxLabel>
                <Text fontSize='$sm' >
                  Ask challenges and discuss.
                </Text>
              </CheckboxLabel>
            </Checkbox>
          </VStack>
          <Fab size='sm' placement='bottom center' top="0" position='relative'>
            <FabIcon as={AddIcon} size='sm'/>
          </Fab>
        </Box>
      `,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Box,
        VStack,
        Checkbox,
        CheckboxIndicator,
        CheckboxLabel,
        CheckboxIcon,
        CheckIcon,
        Fab,
        FabIcon,
        FabLabel,
        Wrapper,
        AddIcon,
        Text,
      },
      argsType: {},
    }}
  />
</Wrapper>

#### Custom Placement

A Fab component with custom placement allows for flexible positioning of the button according to specific design requirements or user interface preferences, providing tailored and intuitive access to key actions or functionalities.

<Wrapper>
  <CodePreview
    _rendererWrapper={{ py: '$8' }}
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
        <Box
          maxWidth='$96'
          borderColor='$borderLight200'
          borderRadius='$lg'
          borderWidth='$1'
          overflow='hidden'
          $base-mx='$5'
          $dark-bg='$backgroundDark900'
          $dark-borderColor='$borderDark800'
        >
          <Box>
            <Image
              h={185}
              w={416}
              source={{
                uri: 'https://images.pexels.com/photos/1937743/pexels-photo-1937743.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2',
              }}
              fallbackSource={{
                uri: 'https://images.pexels.com/photos/1937743/pexels-photo-1937743.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2',
              }}
            />
          </Box>
          <VStack px='$6' pt='$4' pb='$6'>
            <Heading size='sm' >
              Fresh Orange - Imported (Loose)
            </Heading>
            <Text fontSize='$sm'  my='$1.5'>
              Rs 146(Rs.24.33/pc)
            </Text>
            <Text fontSize='$xs'>
              DETAILS
            </Text>
            <Text fontSize='$xs'  my='$1.5'>
              Oranges are a great source of vitamin C, which is essential for a healthy immune system. Oranges are a great source of vitamin C, which is important for maintaining a healthy immune system. Vitamin C also helps with the absorption of iron and the production of collagen, which supports healthy skin, teeth, and bones.
            </Text>
            <Link href="https://gluestack.io/" isExternal>
              <Text fontSize='$xs' color='$pink600'>
                READ MORE
              </Text>
            </Link>
          </VStack>
          <Fab bg='$primary600' size='lg' right='$4' bottom='$20'>
            {/* ShoppingCartIcon is imported from 'lucide-react-native' */}
            <FabIcon as={ShoppingCartIcon} h='$4' w='$4'/>
          </Fab>
        </Box>
      `,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Fab,
        FabIcon,
        FabLabel,
        Wrapper,
        Box,
        Heading,
        Text,
        ShoppingCartIcon,
        Image,
        VStack,
        Link,
      },
      argsType: {},
    }}
  />
</Wrapper>
